//
//  TLSearchView.m
//  Books
//
//  Created by tao故乡的云 on 2017/3/24.
//  Copyright © 2017年 故乡的云. All rights reserved.
//

#import "TLSearchView.h"

@interface TLSearchView ()<UISearchBarDelegate>
@property (weak, nonatomic) IBOutlet UISearchBar *searchBar;
@end

@implementation TLSearchView

+ (instancetype)seachView {
    TLSearchView *search = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil][0];
    search.searchBar.delegate = search;
    search.searchBar.placeholder = @"输入关键字搜索";
    [search.searchBar setShowsCancelButton:NO animated:YES];
    search.searchBar.showsCancelButton = NO;

    return search;
}


#pragma mark - Search Bar Delegate
//- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{
//    
//}

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
    searchBar.showsCancelButton = YES;
}

//- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar;                        // return NO to
//- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar;                       // called when text ends editing
//- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
//    }

//- (BOOL)searchBar:(UISearchBar *)searchBar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text NS_AVAILABLE_IOS(3_0); // called before text changes

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    
}


- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
    searchBar.showsCancelButton = NO;
   
}
- (void)searchBarResultsListButtonClicked:(UISearchBar *)searchBar {
    
}

- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope {
    
}
@end
